package logic

import (
	"context"

	"mail/service/property/api/internal/svc"
	"mail/service/property/api/internal/types"
	"mail/service/property/rpc/property"

	"github.com/zeromicro/go-zero/core/logx"
)

type AlterLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewAlterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AlterLogic {
	return &AlterLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *AlterLogic) Alter(req *types.AlterRequest) (resp *types.AlterResponse, err error) {
	// todo: add your logic here and delete this line
	_, err = l.svcCtx.PropertyRpc.Alter(l.ctx, &property.AlterRequest{
		Id:     req.Id,
		Name:   req.Name,
		Desc:   req.Desc,
		Stock:  req.Stock,
		Amount: req.Amount,
		Status: req.Status,
	})
	if err != nil {
		return nil, err
	}
	return &types.AlterResponse{}, nil
}
